package com.dudu.service.impl;

import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;

import com.dudu.bean.MeetInfoBean;
import com.dudu.dao.MeetInfoDao;
import com.dudu.model.MeetInfo;
import com.dudu.service.IMeetInfoService;

import core.CoreDao;
/**
 * 会议记录数据表
 * @author 危东
 * @date 2016-4-28
 */
public class MeetInfoServiceImpl implements IMeetInfoService {
	//会议信息持久化
	private MeetInfoDao meetImsDao = new MeetInfoDao();
	
	private Logger log =Logger.getLogger(MeetInfoServiceImpl.class.getSimpleName());
	/**
	 * 新增会议记录信息
	 * @param meetInfo
	 * @return
	 * @throws Throwable
	 */
	@Override
	public int insert(CoreDao coreDao,MeetInfoBean meetInfo) throws Throwable {
		log.info("MeetInfoServiceImpl.insert 新增会议记录信息");
		//会议信息实例类model层
		MeetInfo meetInfoModel = new MeetInfo();
		//实体类的转换
		BeanUtils.copyProperties(meetInfo, meetInfoModel);//源,目的
		return meetImsDao.insertMeetIms(coreDao, meetInfoModel);
	}

	/**
	 * 更新被叫与参会人数据
	 * @param dao
	 * @param meetInfo
	 * @return
	 * @throws Throwable
	 */
	@Override
	public int updateMeetImsPhoneAndAcount(CoreDao dao, MeetInfoBean meetInfo) throws Throwable {
		log.info("MeetInfoServiceImpl.updateMeetImsPhoneAndAcount 更新被叫与参会人数据");
		//会议信息实例类model层
		MeetInfo meetInfoModel = new MeetInfo();
		//实体类的转换
		BeanUtils.copyProperties(meetInfo, meetInfoModel);//源,目的
		return meetImsDao.updateMeetImsPhoneAndAcount(dao, meetInfoModel);
		
	}
	
	/**
	 * 根据会议标识查询会议详情
	 * @param dao
	 * @param sessionId
	 * @return
	 */
	@Override
	public MeetInfoBean queryMeetImsBySessionId(CoreDao dao, String sessionId) throws Exception {
		log.info("MeetInfoServiceImpl.queryMeetImsBySessionId 根据会议标识查询会议详情");
		//最终返回结果
		MeetInfoBean meetInfoBean = new MeetInfoBean();
		
		//获取查询的值
		MeetInfo meetInfo = meetImsDao.queryMeetImsBySessionId(dao, sessionId);
		if(meetInfo!=null){
			//实体类的转换
			BeanUtils.copyProperties(meetInfo, meetInfoBean);//源,目的
		}else{
			meetInfoBean=null;
		}
		
		return meetInfoBean;
	}
}
